package com.woniu.goods.controller;

import com.woniu.commons.anno.RequirePerms;
import com.woniu.commons.response.ResponseResult;
import com.woniu.goods.service.GoodsService;
import org.apache.http.HttpStatus;
import org.springframework.web.bind.annotation.*;

import javax.annotation.Resource;

@RestController
@RequestMapping("/goods")
public class GoodsController {
    @Resource
    private GoodsService goodsService;

    @RequestMapping("/test")
    public String test() {
        return "goods test";
    }

    @RequestMapping("/findById")
    public String findById() {
        return "goods findById";
    }

    @RequestMapping("/findAll")
    public String findAll() {
        return "goods findAll";
    }

    //删除
    @DeleteMapping("/delById")
    @RequirePerms("goods:del")
    public ResponseResult<Boolean> delById() {
        return new ResponseResult<>(200, "suucees", true);
    }

    //库存修改
    @PutMapping("/updateStock/{id}/{stock}")
    public ResponseResult<Boolean> updateStock(@PathVariable("id") Integer id, @PathVariable("stock") Integer stock) {
        return new ResponseResult<>(HttpStatus.SC_OK, "suucees", goodsService.updateStock(id, stock));
    }

}